package com.example.init;

import com.example.config.AutoConfig;
import com.example.entity.User;
import com.example.service.UserService;
import com.example.util.ExceptionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class InitConfig implements ApplicationRunner {

    @Autowired
    ExceptionUtil exceptionUtil;

    @Autowired
    UserService userService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        User user=new User();
        user.setAge("20");
        user.setId("sds");
        user.setName("xiaoming");
        userService.doSomething(user);
        System.out.println("user = " + user);
    }

    private void method1() throws InstantiationException, IllegalAccessException {
        int i=0;
        exceptionUtil.assertException(()->i==1, "无效参数");
        AutoConfig autoConfig=null;
        AutoConfig autoConfig1 = exceptionUtil.assertReturn(AutoConfig.class, autoConfig);
    }
}
